package com.example.demo5.Controller;

import com.example.demo5.Service.Impl.StudentService;
import com.example.demo5.jopo.Student;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("student")
public class StudentController {
    @Resource
    private StudentService studentService;
    @RequestMapping("findAll")
    public List<Student> findAll(){
        return studentService.findAll();
    }

    @RequestMapping("add")
    public String add(@RequestBody Student student){
        studentService.add(student);
        return "成功";
    }
    @RequestMapping("edit")
    public void edit(@RequestBody Student student){
        studentService.edit(student);
    }

    @RequestMapping("findById")
    public Student findById(Integer id){
        return studentService.findById(id);
    }
    @RequestMapping("del")
    public void del(Integer id){
        studentService.del(id);
    }

}
